<html>
<head><title>Update Captain</title></head>
<body>
	<center><h2>Updating Captain...</h2></center>
	<?php
		$con = mysql_connect("oniddb.cws.oregonstate.edu","rundej-db","Hp2tYI0CxEY4U9J9");
		if(!$con)
		{
			die('Could not connect: ' . mysql_error());
		}
		mysql_select_db('rundej-db',$con);
		echo $_POST['cname'];
		$query = "SELECT P.Number FROM Players P WHERE P.Lname = '" . $_POST['cname'] . "';";
		$number = mysql_query($query,$con);
		$temp = mysql_fetch_array($number);
		mysql_query("UPDATE Region SET Region.Captain = " . $temp['Number'] . " WHERE Region.Region_Name = '" . $_POST['rname'] . "';",$con); 
	?>	
	<center><table border = "1">
		<tr>
			<th>Region No.</th>
			<th>Region Name</th>
			<th>Captain No.</th>
			<th>Headquarters</th>
			<th>President Name</th>
			<th>Wins</th>
			<th>Losses</th>
			<th>Ties</th>
		</tr>
	<?php
		$region = mysql_query("SELECT * FROM Region");
		while ($row = mysql_fetch_array($region))
		{
			echo "<tr>";
			echo "<td>" . $row['Region_No'] . "</td>";
			echo "<td>" . $row['Region_Name'] . "</td>";
			echo "<td>" . $row['Captain'] . "</td>";
			echo "<td>" . $row['Headquarters'] . "</td>";
			echo "<td>" . $row['President_Name'] . "</td>";
			echo "<td>" . $row['Num_Wins'] . "</td>";
			echo "<td>" . $row['Num_Losses'] . "</td>";
			echo "<td>" . $row['Num_Ties'] . "</td>";
			echo "</tr>";
		}
		mysql_close($con);
	?>
	</table>
	</center>
	<center>
		<a href = "index.php">Home</a>
		<a href = "umpires.php">Umpires</a>
		<a href = "regions.php">Regions</a>
		<a href = "players.php">Players</a>
	</center>
</body>
</html>
